#ifndef _MYSPI_H
#define _MYSPI_H

#include "gd32e230.h"                   // Device header
#include "MyUart.h"


//硬件SPI测试程序   V1.1           修改日期：2025/6/12
//实现功能：SPI0做主机，SPI1做从机 交换数据
//By:TAO XIN YU (陶鑫宇)


//************************************************************************//
//             GPIOA区

#define SPI_0_NSS_PIN 		GPIO_PIN_4
//#define SPI_0_NSS_PIN 		GPIO_PIN_15
#define SPI_0_SCK_PIN 		GPIO_PIN_5
#define SPI_0_MIS0_PIN 		GPIO_PIN_6
#define SPI_0_MOSI_PIN 		GPIO_PIN_7

//#define SPI_1_NSS_PIN 		GPIO_PIN_4
//#define SPI_1_IO2_PIN 		GPIO_PIN_11
//#define SPI_1_IO3_PIN 		GPIO_PIN_12
//#define SPI_1_MIS0_PIN 		GPIO_PIN_13
//#define SPI_1_MOSI_PIN 		GPIO_PIN_14
//#define SPI_1_NSS_PIN 		GPIO_PIN_15


//************************************************************************//
//             GPIOB区

//#define SPI_0_NSS_PIN 		GPIO_PIN_12
//#define SPI_0_SCK_PIN 		GPIO_PIN_3
//#define SPI_0_SCK_PIN 		GPIO_PIN_13
//#define SPI_0_MIS0_PIN 		GPIO_PIN_14
//#define SPI_0_MIS0_PIN 		GPIO_PIN_4
//#define SPI_0_MOSI_PIN 		GPIO_PIN_15
//#define SPI_0_MOSI_PIN 		GPIO_PIN_5

#define SPI_1_NSS_PIN 		GPIO_PIN_12
#define SPI_1_IO2_PIN 		GPIO_PIN_10
#define SPI_1_IO3_PIN 		GPIO_PIN_11
//#define SPI_1_SCK_PIN 		GPIO_PIN_1
//#define SPI_1_SCK_PIN 		GPIO_PIN_10
#define SPI_1_SCK_PIN 		GPIO_PIN_13
#define SPI_1_MIS0_PIN 		GPIO_PIN_14
#define SPI_1_MOSI_PIN 		GPIO_PIN_15

#define buffer_size 10

extern unsigned char spi0_send_buffer[];
extern unsigned char spi0_receive_buffer[];
extern unsigned char spi1_send_buffer[];
extern unsigned char spi1_receive_buffer[];


void MySPI_init(void);

#endif
